import Vue from "vue";

import "normalize.css/normalize.css"; // A modern alternative to CSS resets

import ElementUI from "element-ui";
import "element-ui/lib/theme-chalk/index.css";
import locale from "element-ui/lib/locale/lang/en"; // lang i18n

import "@/styles/index.scss"; // global css

import App from "./App";
import store from "./store";
import router from "./router";

import "@/icons"; // icons
import "@/permission"; // permission control

// set ElementUI lang to EN
// Vue.use(ElementUI, { locale });
// 如果想要中文版 element-ui，按如下方式声明
Vue.use(ElementUI, { size: "small" });

import TlbsMap from "tlbs-map-vue";
Vue.use(TlbsMap);

Vue.config.productionTip = false;

import { convertToPinyinString, FIRST_LETTER } from "pinyin4js";
String.prototype.localeCompareTo = String.prototype.localeCompare;
String.prototype.localeCompare = function (b) {
  let pinyinA = convertToPinyinString(this, "", FIRST_LETTER);
  let pinyinB = convertToPinyinString(b, "", FIRST_LETTER);
  return pinyinA.localeCompareTo(pinyinB);
};

new Vue({
  el: "#app",
  router,
  store,
  render: (h) => h(App),
});

function loadScript() {
  let script = document.createElement("script");
  script.type = "text/javascript";
  script.src =
    "https://map.qq.com/api/gljs?v=1.exp&key=OB4BZ-D4W3U-B7VVO-4PJWW-6TKDJ-WPB77&callback=initMap";
  document.body.appendChild(script);
}
window.addEventListener("load", loadScript);
